# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :create_app.py
# @Time      :2022/7/21 15:33
# @Author    :吕华龙
from settings.config import DevConfig
from flask import Flask
from flask_cors import CORS
from flask_migrate import Migrate
from models.model import db
from views.users import user_bp
from views.teachers import teacher_bp
from views.course import cour_bp
from views.order import order_bp
from views.channel import channel_bp
from views.information import infor_bp
from views.appraise import appraise_bp
from views.users import stu_login


# from utils.cache import *


def create_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    CORS(app)
    db.init_app(app)
    Migrate(app, db)
    # cache.init_app(app)
    app.register_blueprint(user_bp)
    app.register_blueprint(teacher_bp)
    app.register_blueprint(cour_bp)
    app.register_blueprint(order_bp)
    app.register_blueprint(channel_bp)
    app.register_blueprint(infor_bp)
    app.register_blueprint(appraise_bp)

    app.before_request(stu_login)

    return app
